package com.zhoug.zmui3demo.ui;

import android.graphics.Color;
import android.os.Bundle;
import android.widget.Button;

import com.zhoug.zmui3.ZMUIWaveProgressView;
import com.zhoug.zmui3demo.R;

import java.util.Random;

import androidx.appcompat.app.AppCompatActivity;

public class WaveProgressViewActivity extends AppCompatActivity {

    private Button mBtnAnim;
    private ZMUIWaveProgressView mZMUIWaveProgressView;
    private Button mBtnValue;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_wave_progress_view);
        findViews();
        mBtnAnim.setOnClickListener(v->{
            if(mZMUIWaveProgressView.isAnimRunning()){
                mZMUIWaveProgressView.stopWaveAnim();
            }else{
                mZMUIWaveProgressView.startWaveAnim();
            }

        });
        mZMUIWaveProgressView.setProgress(0.6f);
        mZMUIWaveProgressView.setTexts("延期上传","上传有误");
        mZMUIWaveProgressView.setTextColors(Color.WHITE,Color.parseColor("#ff8888"));

        mZMUIWaveProgressView.startProgressAnim(1000);
        mZMUIWaveProgressView.startWaveAnim();


        mBtnValue.setOnClickListener(v->{
            Random random=new Random();
            float progress = random.nextInt(101)/100f;
//            mZMUIWaveProgressView.setProgress(progress);
            mZMUIWaveProgressView.animUpdateProgress(progress,1000);
            mZMUIWaveProgressView.startWaveAnim();
            mBtnValue.setText("随机值:"+progress);
        });
    }

    private void findViews() {
        mBtnAnim = findViewById(R.id.btn_anim);
        mZMUIWaveProgressView = findViewById(R.id.ZMUIWaveProgressView);
        mBtnValue = findViewById(R.id.btn_value);
    }
}